package impl;

import anaydis.sort.SorterType;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class HSorter extends AbstractSorter{

    private static final int H = 11;
    public HSorter() {
        super(SorterType.H);
    }public HSorter(SorterType sorterType) {
        super(sorterType);
    }

    public <T> void sort(Comparator<T> comparator, List<T> list) {
       sort(comparator,list,H);
    }
    public <T> void sort(Comparator<T> comparator, List<T> list,int h) {
        int tope = list.size();
        for (int i = h; i < tope; i++) {
            for (int j = i; j >= h; j-=h) {
                if (greater(comparator, list, j-h , j)) {
                    swap(list, j-h, j);
                }else{
                    break;
                }

            }

        }
    }

}
